function deepClone(obj,map = new WeakMap()) {
    if(typeof obj === null) return obj;
    if(obj instanceof Date) return obj;
    if(obj instanceof RegExp) return obj;
    if(typeof obj !== 'object') return obj;
    if(map.has(obj)) return map.get(obj);
    const cloneObj = new obj.constructor;
    map.set(obj,cloneObj);
    for(let key in obj) {
        if(obj.hasOwnProperty(key)){
            cloneObj[key] = deepClone(obj[key],map);
        }
    }
    return cloneObj;
}

let obj = {name:'张润钊',age: 21, job: { address: '深圳', job:  {job:'前端'}}};
const cloneObj = deepClone(obj)
obj.name = "瓜皮"
obj.job.address = "广州"
obj.job.job = "后台"
console.log(obj)
console.log(cloneObj);

